<style>
.webboard-button{padding:10px 0;}
.pagination{float:right;}
.webboard-view{width:100%;border:1px solid #ddd; background:#FFF;}
.webboard-view tr.head th,.webboard-view tr.head td{padding:10px 0;vertical-align:middle;}
.webboard-view tr.head td{padding:10px;font-size:16px;color:#5a9fd8;}
.webboard-view tr.head td img{margin-right:10px;}
.webboard-view tr th, .webboard-view tr td{font-weight:normal;}
.webboard-view tr th{width:160px;background:#E5EDF2;border-top:4px solid #C2D5E3;border-bottom:4px solid #C2D5E3;border-right:0px solid #C2D5E3;}
.webboard-view tr td{border-top:4px solid #E5EDF2;border-bottom:4px solid #E5EDF2;padding:0 10px;}
.webboard-view tr td.content{vertical-align:text-top;}
.webboard-view .label{color:#888;}
.webboard-view .user-display{padding:10px 0;border-bottom:1px dashed #ccc;}
.webboard-view .user-image{margin:10px auto;width:80px;padding:5px;background:#fff;border:1px solid #eee;text-align:center;}
.webboard-view .user-image img{width:100%;}
.webboard-view .user-info{padding:0 0 10px 0;font-size:13px;color:#888;}
.webboard-view .post-info{padding:10px 0;border-bottom:1px dashed #ccc;font-size:13px;color:#888;}
.webboard-view .post-content{padding:10px 0;line-height:20px;}
.webboard-view .post-image{text-align:center;padding-bottom:10px;}
.webboard-view .post-update{font-size:12px;color:#aaa;font-style:italic;}
a.edit:link, a.edit:visited{color:green;}
a.delete:link, a.delete:visited{color:red;}
</style>
	<div id="breadcrumb"><ul><li><a href="">หน้าแรก</a></li><span>»</span><li><a href="webboard">เว็บบอร์ด</a></li><span>»</span><li><a href="webboard/topics/index/<?php echo $topic->webboard_category_id ?>"><?php echo $topic->webboard_category->name ?></a></li></ul><div class="clear"></div></div>
	<h1 class="orange"><?php echo $topic->title?></h1>
	<div class="clear"></div>
	<div id="content-data" class="box">
		<div id="module-webboard" class="view">
			<div class="webboard-button">
				<a href="webboard/topics/form"><img src="media/images/pn_post.png"></a>
				<a href="webboard/replies/form/<?php echo $topic->id?>"><img src="media/images/pn_reply.png"></a>
				<?php echo $topics->pagination()?>
				<div class="clear"></div>
			</div>			
			<table class="webboard-view">
				<tr class="head">
					<th><span class="label">ดู:</span> <?php echo number_format($topic->counter)?> | <span class="label">ตอบ:</span> <?php echo $topic->reply->get()->result_count()?></th>
					<td class="topic-label"><img src="media/images/webboard-view-topic.png" align="left" /> <?php echo $topic->title?></td>
				</tr>
				<?php foreach($topics as $reply):?>
				<tr>
					<th>
						<div class="user-display"><?php echo ($reply->user_id) ? $reply->user->display : $reply->author?></div>
						<div class="user-image"><img src="<?php echo (is_file('uploads/user/'.$reply->user->image)) ? 'uploads/user/'.$reply->user->image : 'media/images/noavatar.gif'?>" /></div>
						<div class="user-info">
							<p><?php echo ($reply->user_id) ? $reply->user->level->title : 'บุคคลทั่วไป'?></p>
						</div>
					</th>
					<td class="content">
						<div class="post-info">
							โพสต์เมื่อ <?php echo mysql_to_th($reply->created,'F',TRUE)?>
							<?php 
							if(is_login() && ( user()->level_id < 3 OR user()->id == $reply->user_id ))
							{
								echo ($reply->topic_id) 
								? ' - '.anchor('webboard/replies/form/'.$topic->id.'/'.$reply->id,'แก้ไข','class="edit"')
								: ' - '.anchor('webboard/topics/form/'.$reply->id,'แก้ไข','class="edit"');
								echo ($reply->topic_id) 
								? ' - '.anchor('webboard/replies/delete/'.$topic->id.'/'.$reply->id,'ลบ','class="delete" onclick="return confirm(\'ยืนยันการลบ\')"')
								: ' - '.anchor('webboard/topics/delete/'.$reply->id,'ลบ','class="delete" onclick="return confirm(\'ยืนยันการลบ\')"');
							}
							?>
						</div>
						<div class="post-content"><?php echo $reply->content?></div>
						<div class="post-image"><?php echo ($reply->image) ? '<img src="uploads/webboard/'.$reply->image.'" />' : NULL?></div>
						<div class="post-update"><?php echo ($reply->modified) ? 'แก้ไขล่าสุด '.mysql_to_th($reply->modified,'F',TRUE) : NULL?></div>
					</td>
				</tr>
				<?php endforeach?>
			</table>
			<div class="webboard-button">
				<a href="webboard/topics/form"><img src="media/images/pn_post.png"></a>
				<a href="webboard/replies/form/<?php echo $topic->id?>"><img src="media/images/pn_reply.png"></a>
				<?php echo $topics->pagination()?>
				<div class="clear"></div>
			</div>	
		</div>
	</div>